package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mappers.SoulQuestionsMapper;
import com.tanhua.model.testpaper.SoulQuestions;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
@Slf4j
@DubboService
public class SoulQuestionsApiImpl implements SoulQuestionsApi {
    @Autowired
    private SoulQuestionsMapper soulQuestionsMapper;

    //批量查询题目
    @Override
    public List<SoulQuestions> findBySoulPaperIds(List<Long> soulPaperIds) {
        List<SoulQuestions>list=new ArrayList<>();
        for (Long soulPaperId : soulPaperIds) {
            LambdaQueryWrapper<SoulQuestions> lqw = new LambdaQueryWrapper<>();
            lqw.eq(SoulQuestions::getPaperId, soulPaperId);
            List<SoulQuestions> soulQuestions = soulQuestionsMapper.selectList(lqw);
            for (SoulQuestions soulQuestion : soulQuestions) {
                list.add(soulQuestion);
            }
        }
        log.info(list.toString());
        return list;
    }

    @Override
    public List<SoulQuestions> findAll() {

        List<SoulQuestions> soulQuestions = soulQuestionsMapper.selectList(new LambdaQueryWrapper<>());

        return soulQuestions;
    }
}
